package com.huawei.appgallery.forum.forum.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.forum.base.card.bean.Section;
import com.huawei.appgallery.forum.forum.bean.ForumSectionInfoCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.widget.CardListAdapter;
import java.util.ArrayList;
import java.util.List;
import o.azb;
import o.bst;
import o.bun.c;
import o.bun.d;
import o.bvf;
import o.cia;
import o.eqx;
import o.evx;

public class ForumDetailListAdapter extends CardListAdapter {
    private static final String TAG = "ForumDetailListAdapter";
    private Context context;
    private List<ForumSectionInfoCardBean> dataList = new ArrayList();

    static class e {
        public ImageView ʻ;
        public TextView ʼ;
        public TextView ʽ;
        public TextView ˊ;
        public RelativeLayout ˋ;
        public View ˋॱ;
        public TextView ˎ;
        public ImageView ˏ;
        public View ˏॱ;
        public TextView ॱ;
        public TextView ॱॱ;
        public RelativeLayout ᐝ;

        private e() {
        }
    }

    public ForumDetailListAdapter(Context context, cia o_cia) {
        super(context, o_cia);
        this.context = context;
    }

    public int getCount() {
        if (this.dataList == null) {
            return 0;
        }
        return (this.dataList.size() + 1) / 2;
    }

    public Object getItem(int i) {
        return this.dataList.get(i);
    }

    public long getItemId(int i) {
        return (long) i;
    }

    public View getView(int i, View view, ViewGroup viewGroup) {
        e eVar;
        if (view == null) {
            view = LayoutInflater.from(this.context).inflate(d.ˋ, viewGroup, false);
            e eVar2 = new e();
            initViewHolder(view, eVar2);
            view.setTag(eVar2);
            eVar = eVar2;
        } else {
            eVar = (e) view.getTag();
        }
        if (this.dataList != null && this.dataList.size() > 0) {
            final Section ˊ;
            ForumSectionInfoCardBean forumSectionInfoCardBean = (ForumSectionInfoCardBean) this.dataList.get(i * 2);
            if (!(forumSectionInfoCardBean == null || forumSectionInfoCardBean.ˊ() == null)) {
                ˊ = forumSectionInfoCardBean.ˊ();
                if (ˊ != null) {
                    eqx.ˏ(eVar.ˏ, ˊ.ॱ(), "app_default_icon");
                    eVar.ˎ.setText(ˊ.ˏ());
                    eVar.ˊ.setText(bst.ॱ(this.context, ˊ.ˎ()));
                    eVar.ॱ.setText(bst.ॱ(this.context, (long) ˊ.ʻ()));
                    eVar.ˋ.setOnClickListener(new evx(this) {
                        final /* synthetic */ ForumDetailListAdapter ॱ;

                        public void ˋ(View view) {
                            bvf.ˋ().ˊ(this.ॱ.context, ˊ, eVar.ॱ);
                        }
                    });
                }
            }
            if ((i * 2) + 1 < this.dataList.size()) {
                eVar.ˏॱ.setVisibility(0);
                eVar.ᐝ.setVisibility(0);
                forumSectionInfoCardBean = (ForumSectionInfoCardBean) this.dataList.get((i * 2) + 1);
                if (!(forumSectionInfoCardBean == null || forumSectionInfoCardBean.ˊ() == null)) {
                    ˊ = forumSectionInfoCardBean.ˊ();
                    if (ˊ != null) {
                        eqx.ˏ(eVar.ʻ, ˊ.ॱ(), "app_default_icon");
                        eVar.ʼ.setText(ˊ.ˏ());
                        eVar.ʽ.setText(bst.ॱ(this.context, ˊ.ˎ()));
                        eVar.ॱॱ.setText(bst.ॱ(this.context, (long) ˊ.ʻ()));
                        eVar.ᐝ.setOnClickListener(new evx(this) {
                            final /* synthetic */ ForumDetailListAdapter ॱ;

                            public void ˋ(View view) {
                                bvf.ˋ().ˊ(this.ॱ.context, ˊ, eVar.ॱॱ);
                            }
                        });
                    }
                }
            } else {
                eVar.ˏॱ.setVisibility(4);
                eVar.ᐝ.setVisibility(4);
            }
            eVar.ˋॱ.setVisibility(0);
            if (i == getCount() - 1) {
                eVar.ˋॱ.setVisibility(8);
            }
        }
        return view;
    }

    private void initViewHolder(View view, e eVar) {
        View findViewById = view.findViewById(c.ˋˊ);
        eVar.ˋ = (RelativeLayout) findViewById.findViewById(c.ˊˋ);
        azb.ˊ(eVar.ˋ);
        eVar.ˏ = (ImageView) findViewById.findViewById(c.ᐧ);
        eVar.ˎ = (TextView) findViewById.findViewById(c.ᐝᐝ);
        eVar.ˊ = (TextView) findViewById.findViewById(c.ـ);
        eVar.ॱ = (TextView) findViewById.findViewById(c.ˏॱ);
        findViewById = view.findViewById(c.ˊᐝ);
        eVar.ᐝ = (RelativeLayout) findViewById.findViewById(c.ˊˋ);
        azb.ˎ(eVar.ᐝ);
        eVar.ʻ = (ImageView) findViewById.findViewById(c.ᐧ);
        eVar.ʼ = (TextView) findViewById.findViewById(c.ᐝᐝ);
        eVar.ʽ = (TextView) findViewById.findViewById(c.ـ);
        eVar.ॱॱ = (TextView) findViewById.findViewById(c.ˏॱ);
        eVar.ᐝ.setPaddingRelative(eVar.ᐝ.getPaddingStart(), 0, eVar.ᐝ.getPaddingEnd() + this.context.getResources().getDimensionPixelOffset(o.bsy.e.ॱˎ), 0);
        eVar.ˏॱ = view.findViewById(c.ˋॱ);
        eVar.ˋॱ = view.findViewById(c.ᐝ);
        azb.ˋ(eVar.ˋॱ);
    }

    public void setListSection(List<ForumSectionInfoCardBean> list) {
        this.dataList.addAll(list);
        notifyDataSetChanged();
    }

    public void clear() {
        this.dataList.clear();
        notifyDataSetChanged();
    }

    public List<ForumSectionInfoCardBean> getDataList() {
        return this.dataList;
    }
}
